<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 导入semantic的样式 -->
<jsp:include page="../head.jsp">
	<jsp:param value="客户界面-前台管理界面" name="title" />
</jsp:include>
<script type="text/javascript">
	$(function() {
		var ids = [];
		$("#assignCustom").on("click", function() {
			ids = [];
			var checkeds = $(".item-check:checked");
			checkeds.each(function() {
				ids.push(this.value);
			});
			if (ids.length) {
				$('.ui.modal').modal('show');
			}
		});
		var s = $('#employee');
		s.on("click", "a", function() {
			if (confirm("确认要如此分配吗？")) {
				location.replace("custom/assign?empid=" + $(this).attr('value')
						+ "&id=" + ids.join("&id="))
			}
		});
	});
	function menuChange(target) {
		//	alert($(target).attr("value"));
		var sondeptEl = document.getElementById("sondept");
		var employeeEl = document.getElementById("employee");
		sondeptEl.innerHTML = "";
		employeeEl.innerHTML = "";
		ajax({
			url : "custom/assignajax?type=sondept&bigdeptid="
					+ $(target).attr("value"),
			callback : function(xhr) {
				var data;
				// 两种方式
				// JSON.parse(xhr.response);
				if (window.JSON) {
					data = JSON.parse(xhr.response);
				} else {
					data = eval("(" + xhr.response + ")");
				}
				if (data) {
					for (var i = 0; i < data.length; i++) {
						var item = data[i];
						var pp = document.createElement("p");
						var op = document.createElement("span");
						$(op).attr("value", item.dept_id);
						$(op).attr("onclick", "sonDeptChange(this)");
						$(op).css({
							"margin-left" : "20px",
							"font-size" : "18px"
						});
						op.innerText = item.dept_name;
						pp.appendChild(op);
						sondeptEl.appendChild(pp);
					}
					//				sonDeptChange(sondeptEl);
				}
			}
		});
	}
	//选择出员工
	function sonDeptChange(target) {
		var employeeEl = document.getElementById("employee");
		employeeEl.innerHTML = "";
		ajax({
			url : "custom/assignajax?type=area&sondeptid="
					+ $(target).attr("value"),
			callback : function(xhr) {
				var data;
				// 两种方式
				// JSON.parse(xhr.response);
				if (window.JSON) {
					data = JSON.parse(xhr.response);
				} else {
					data = eval("(" + xhr.response + ")");
				}
				if (data) {
					for (var i = 0; i < data.length; i++) {
						var item = data[i];
						var p = document.createElement("p");
						var a = document.createElement("a");
						$(a).attr("value", item.empId);
						a.innerText = item.empName;
						$(a).attr("class", "aaaa");
						$(p).css({
							"margin-left" : "20px",
							"font-size" : "18px"/*,"margin-top":"10px"*/
						});
						p.appendChild(a);
						employeeEl.appendChild(p);
					}
				}
			}
		});
	}
</script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div id="content" class="col-lg-12">
				<div class="dao">
					<p>客户管理</p>
				</div>
				<div class="row">
					<div class="col-md-12">
						<!-- BOX -->
						<div class="box border blue">
							<div class="box-title">
								<h4>客户列表</h4>
							</div>
							<div class="dataTables_header clearfix">
								<div style="padding: 10px">
									<button class="ui inverted brown button" id="assignCustom">分配客户</button>
									<button class="ui inverted red button" id="deleteCustom">删除</button>
									<a href="custom/form"><button
											class="ui inverted blue button">新建</button></a> ${error }
									<div class="ui fluid category search" style="float: right;">
										<div class="ui icon input">
											<form action="custom">
												<input class="prompt" type="text" name="search"
													style="height: 30px" placeholder="请输入关键字，回车查询"
													value="${param.search }">
											</form>
										</div>
									</div>
								</div>
							</div>
							<div class="box-body center">
								<table id="datatable2" cellpadding="0" cellspacing="0"
									border="0"
									class="datatable table table-striped table-bordered table-hover">
									<thead>
										<tr style="text-align: center">
											<th>
												<div>
													<input type="checkbox" id="checkAll"><label></label>
												</div>
											</th>
											<th>姓名</th>
											<th>性别</th>
											<th>学历</th>
											<th>客户来源</th>
											<th>电话</th>
											<th>qq</th>
											<th>家庭住址</th>
											<th>编辑</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${ customList}" var="custom">
											<tr class="gradeX">
												<td>
													<div>
														<input class="item-check" type="checkbox"
															value="${ custom.customId}"><label></label>
													</div>
												</td>
												<td>${ custom.customName}</td>
												<td>${ custom.customGender}</td>
												<td>${ custom.degreeName}</td>
												<td>${ custom.customSource}</td>
												<td>${ custom.customTel}</td>
												<td>${ custom.customQQ}</td>
												<td>${ custom.customAddress}</td>
												<td><a href="custom/details?id=${custom.customId }"><i
														class="icon edit"></i> </a></td>
											</tr>
<<<<<<< HEAD
										</thead>
										<tbody>
											<c:forEach items="${ customList}" var="custom">
												<tr class="gradeX">
													<td>
														<div>
															<input class="item-check" type="checkbox"
																value="${ custom.customId}"><label></label>
														</div>
													</td>
													<td>${ custom.customName}</td>
													<td>${ custom.customGender}</td>
													<td>${ custom.degreeName}</td>
													<td>${ custom.customSource}</td>
													<td>${ custom.customTel}</td>
													<td>${ custom.customQQ}</td>
													<td>${ custom.customAddress}</td>
													<td><a href="custom/details?id=${custom.customId }"><i
															class="icon edit"></i> </a></td>
												</tr>
											</c:forEach>
											<c:if test="${empty customList}">
												<tr>
													<td style="text-align: center;" colspan="9">暂无记录</td>
												</tr>
											</c:if>
										</tbody>
									</table>
									<c:if test="${totalPage > 1 }">
										<a
											<c:if test="${page!=1}">href="custom?page=1${queryString}"</c:if>
											class="${page == 1?'disable':''}">首页</a>
										<a
											<c:if test="${page!=1}">href="custom?page=${page-1}${queryString}"</c:if>
											class="${page == 1?'disable':''}">上一页</a>
										<a
											<c:if test="${page!=totalPage}">href="custom?page=${page+1 }${queryString}"</c:if>
											class="${page == totalPage?'disable':''}">下一页</a>
										<a
											<c:if test="${page!=totalPage}">href="custom?page=${totalPage }${queryString}"</c:if>
											class="${page == totalPage?'disable':''}">最后一页</a>
										<span style="float: right"> ${page}/${ totalPage} </span>
									</c:if>
								</div>
=======
										</c:forEach>
										</div>
										</div>
										<!-- /BOX -->
										</div>
										</div>
										<c:if test="${empty customList}">
											<tr>
												<td style="text-align: center;" colspan="9">暂无记录</td>
											</tr>
										</c:if>
									</tbody>
								</table>
								<c:if test="${totalPage > 1 }">
									<a
										<c:if test="${page!=1}">href="custom?page=1${queryString}"</c:if>
										class="${page == 1?'disable':''}">首页</a>
									<a
										<c:if test="${page!=1}">href="custom?page=${page-1}${queryString}"</c:if>
										class="${page == 1?'disable':''}">上一页</a>
									<a
										<c:if test="${page!=totalPage}">href="custom?page=${page+1 }${queryString}"</c:if>
										class="${page == totalPage?'disable':''}">下一页</a>
									<a
										<c:if test="${page!=totalPage}">href="custom?page=${totalPage }${queryString}"</c:if>
										class="${page == totalPage?'disable':''}">最后一页</a>
									<span style="float: right"> ${page}/${ totalPage} </span>
								</c:if>
>>>>>>> refs/remotes/origin/lzt-dev
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="ui small modal" style="width: 500px">
				<i class="close icon"></i>
				<div class="header">选择咨询师</div>

				<div class=" content"
					style="margin-top: 10px; text-align: left; width: 500px; height: 200px;">
					<div style="float: left; border: 1px solid black">
						<div style="width: 150px; height: 150px;">
							<span id="zongDept" onclick="menuChange(this)"
								value="${ xiaoshoubu.dept_id}"
								style="margin-left: 20px; margin-top: 50px; font-size: 18px">${ xiaoshoubu.dept_name}</span>
						</div>
						<div id="sondept"
							style="width: 150px; height: 150px; margin: 3px;"></div>
					</div>
					<div
						style="float: left; border: 1px solid black; margin-left: 3px;">
						<div id="employee" style="width: 280px; height: 305px;"></div>
					</div>
				</div>
			</div>
</body>
</html>